package com.jindy.module.rushBaseView.service.impl;

import java.math.BigDecimal;
import java.util.List;

import com.jindy.module.rushBaseView.domain.RushBaseViewSearchVO;
import com.jindy.module.rushBaseView.domain.RushBaseViewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jindy.module.rushBaseView.mapper.RushBaseViewMapper;
import com.jindy.module.rushBaseView.domain.RushBaseView;
import com.jindy.module.rushBaseView.service.IRushBaseViewService;

/**
 * 催收基表Service业务层处理
 * 
 * @author jindy
 * @date 2023-06-07
 */
@Service
public class RushBaseViewServiceImpl implements IRushBaseViewService 
{
    @Autowired
    private RushBaseViewMapper rushBaseViewMapper;

    /**
     * 查询催收基表
     * 
     * @param logisticsTime 催收基表主键
     * @return 催收基表
     */
    @Override
    public RushBaseView selectRushBaseViewByLogisticsTime(String logisticsTime)
    {
        return rushBaseViewMapper.selectRushBaseViewByLogisticsTime(logisticsTime);
    }

    /**
     * 查询催收基表列表
     * 
     * @param rushBaseViewSearchVO 催收基表
     * @return 催收基表
     */
    @Override
    public List<RushBaseViewVO> selectRushBaseViewList(RushBaseViewSearchVO rushBaseViewSearchVO)
    {
        List<RushBaseViewVO> rushBaseViewVOList = rushBaseViewMapper.selectRushBaseViewSumList(rushBaseViewSearchVO);
        for (RushBaseViewVO rushBaseViewVO : rushBaseViewVOList) {
            rushBaseViewVO.setDepositRemainDays(rushBaseViewVO.getRefundableRentSum().divide(rushBaseViewVO.getTotalDailyRentSum(),0, BigDecimal.ROUND_FLOOR));
        }
        return rushBaseViewVOList;
    }

    /**
     * 新增催收基表
     * 
     * @param rushBaseView 催收基表
     * @return 结果
     */
    @Override
    public int insertRushBaseView(RushBaseView rushBaseView)
    {
        return rushBaseViewMapper.insertRushBaseView(rushBaseView);
    }

    /**
     * 修改催收基表
     * 
     * @param rushBaseView 催收基表
     * @return 结果
     */
    @Override
    public int updateRushBaseView(RushBaseView rushBaseView)
    {
        return rushBaseViewMapper.updateRushBaseView(rushBaseView);
    }

    /**
     * 批量删除催收基表
     * 
     * @param logisticsTimes 需要删除的催收基表主键
     * @return 结果
     */
    @Override
    public int deleteRushBaseViewByLogisticsTimes(String[] logisticsTimes)
    {
        return rushBaseViewMapper.deleteRushBaseViewByLogisticsTimes(logisticsTimes);
    }

    /**
     * 删除催收基表信息
     * 
     * @param logisticsTime 催收基表主键
     * @return 结果
     */
    @Override
    public int deleteRushBaseViewByLogisticsTime(String logisticsTime)
    {
        return rushBaseViewMapper.deleteRushBaseViewByLogisticsTime(logisticsTime);
    }
}
